# @Time : 2020/6/28 13:48
# @Author : Fioman 
# @Phone : 13149920693

import time
import functools


def clock(func):
    @functools.wraps(func)
    def clocked(*args, **kwargs):
        t_start = time.perf_counter()
        res = func(*args, **kwargs)
        elapsed = time.perf_counter() - t_start
        name = func.__name__
        arg_lst = []
        if args:
            arg_lst.append(", ".join(repr(arg) for arg in args))

        if kwargs:
            pairs = ["%s=%r" % (k, v) for k, v in sorted(kwargs.items())]
            arg_lst.append(", ".join(pairs))
        arg_str = ", ".join(arg_lst)

        print("{} {}({}) -> {}".format(elapsed, name, arg_str, res))
        return res

    return clocked


